<?php 


/** 
***************************************************
*欢迎使用免费版xSite企业自助建站软件！
*这是一个专业为搜索引擎营销而设计的，极稳定、极易维护的建站软件！
*官方客服：help@php.net.cn
*官方下载网址：http://www.php.net.cn/xsite/ 
***************************************************
**/




if(!defined('IN_SITETEAM')) { exit('Access Denied'); } if (!empty($_POST['dosubmit'])) { $savedata = $_POST['data']; $system_category_file = SITE_ROOT . "/data/setting/{$site_url}/system.category.txt"; if (empty($savedata['category']) || empty($savedata['name']) || empty($savedata['module'])) { message("xsite.php?action=nav&operation=category", "缺少必填项！"); } if (!preg_match("/^[a-zA-Z]+[\w_]+$/i", $savedata['category'])) { message("xsite.php?action=nav&operation=category", "分类ID只能是英文字母以下下划线，且只能以英文字线开头！"); } if (isset($savedata['parent_category']) && $savedata['parent_category'] !== '') { if (!array_key_exists($savedata['parent_category'], $system_category)) { message("xsite.php?action=nav&operation=category", "父级分类ID必须存在系统上级分类中..."); } } if (!preg_match("/^[a-zA-Z]+[\w_]+$/i", $savedata['main_tpl']) || !preg_match("/^[a-zA-Z]+[\w_]+$/i", $savedata['list_tpl']) || !preg_match("/^[a-zA-Z]+[\w_]+$/i", $savedata['detailed_tpl'])) { message("xsite.php?action=nav&operation=category", "模板文件名只能是英文字母以下下划线，且只能以英文字线开头！"); } if (!file_exists(SITE_DIR . "/templates/{$skinid}/{$savedata['main_tpl']}.htm.php") && !file_exists(SITE_DIR . "/templates/{$skinid}/{$savedata['main_tpl']}.htm")) { message("xsite.php?action=nav&operation=category", "频道首页模板文件[ /templates/{$skinid}/{$savedata['main_tpl']}.htm.php ]不存在，设置无效！"); } if (!file_exists(SITE_DIR . "/templates/{$skinid}/{$savedata['list_tpl']}.htm.php") && !file_exists(SITE_DIR . "/templates/{$skinid}/{$savedata['list_tpl']}.htm")) { message("xsite.php?action=nav&operation=category", "列表页模板文件[ /templates/{$skinid}/{$savedata['list_tpl']}.htm.php ]不存在，设置无效！"); } if (!file_exists(SITE_DIR . "/templates/{$skinid}/{$savedata['detailed_tpl']}.htm.php") && !file_exists(SITE_DIR . "/templates/{$skinid}/{$savedata['detailed_tpl']}.htm")) { message("xsite.php?action=nav&operation=category", "详细内容页模板文件[ /templates/{$skinid}/{$savedata['detailed_tpl']}.htm.php ]不存在，设置无效！"); } $system_category = get_sys_category($site_url); if(!empty($savedata['oldcategory'])) { if ($savedata['oldcategory'] != $savedata['category']) { if (array_key_exists($savedata['category'], $system_category)) { message("xsite.php?action=nav&operation=category", "该分类ID已经存在，请另选ID！"); } if (in_array($savedata['category'], array('block', 'thumb', 'media', 'theme', 'admin', 'public', 'page', 'article', 'product'))) { message("xsite.php?action=nav&operation=category", "分类ID不可用"); } if (file_exists("{$user_data_dir}/{$savedata['oldcategory']}")) { if (!rename("{$user_data_dir}/{$savedata['oldcategory']}", "{$user_data_dir}/{$savedata['category']}")) { message("xsite.php?action=nav&operation=category", "分类ID更改不成功，请检查相应的文件目录权限！"); } } else { if (!mkdir("{$user_data_dir}/{$savedata['category']}")) { message("xsite.php?action=nav&operation=category", "分类ID更改不成功，请检查相应的文件目录权限！"); } } $child_category = cat_subcategory($savedata['oldcategory'], $system_category); if (is_array($child_category) && count($child_category)) { foreach ($child_category as $k => $v) { $system_category[$k]['parent_category'] = $savedata['category']; } } $data = array(); $data['category'] = $savedata['category']; if (!$db->update("{$site_id}_product", $data, " `category` = '{$savedata['oldcategory']}' ")) { ; } } unset($system_category[$savedata['oldcategory']]); } else { if (array_key_exists($savedata['category'], $system_category)) { message("xsite.php?action=nav&operation=category", "该分类ID已经存在，请另选ID！"); } if (in_array($savedata['category'], array('block'))) { message("xsite.php?action=nav&operation=category", "分类ID不可用"); } if (!file_exists("{$user_data_dir}/{$savedata['category']}")) mkdir("{$user_data_dir}/{$savedata['category']}"); if (!file_exists($system_category_file)) fclose(fopen($system_category_file, "w")); } $system_category[$savedata['category']] = array ( "name" => !empty($savedata['name']) ? preg_replace("/[\s]+/", " ", strip_tags($savedata['name'])) : "", "icon" => !empty($savedata['icon']) ? strip_tags($savedata['icon']) : "", "parent_category" => !empty($savedata['parent_category']) ? strip_tags($savedata['parent_category']) : "", "sortid" => !empty($savedata['sortid']) ? strip_tags($savedata['sortid']) : "1", "main_tpl" => !empty($savedata['main_tpl']) ? strip_tags($savedata['main_tpl']) : "product", "list_tpl" => !empty($savedata['list_tpl']) ? strip_tags($savedata['list_tpl']) : "product_list", "detailed_tpl" => !empty($savedata['detailed_tpl']) ? strip_tags($savedata['detailed_tpl']) : "product_detailed", "display" => !empty($savedata['display']) ? strip_tags($savedata['display']) : '1', "seo_title" => !empty($savedata['seo_title']) ? preg_replace("/[\s]+/", " ", strip_tags($savedata['seo_title'])) : "", "seo_description" => !empty($savedata['seo_description']) ? preg_replace("/[\s]+/", " ", strip_tags($savedata['seo_description'])) : "", "seo_keywords" => !empty($savedata['seo_keywords']) ? preg_replace("/[\s]+/", " ", strip_tags($savedata['seo_keywords'])) : "", "module" => $savedata['module'] ); ksort($system_category); foreach ($system_category as $k=>$v) { $sortid[$k] = array_key_exists("sortid", $v) ? $v['sortid'] : 0; } array_multisort($sortid, SORT_NUMERIC, SORT_DESC, $system_category); save_array_file($system_category, $system_category_file, "w+"); cache_update("setting"); message("xsite.php?action=nav&operation=category", "更新分类信息成功！"); } else { $system_category = get_sys_category($site_url); $form['category'] = array ( 'form' => 'input', "type"=>"text", "name" => "<strong>分类ID</strong>", "class" => "txt", "description" => "必须以英文字母开头且只能是英文字母及数字，且必填", 'width' => '300px', 'height' => '18px' ); $form['name'] = array ( 'form' => 'input', "type"=>"text", "name" => "分类名称", "class" => "txt", "description" => "必填项", 'width' => '300px', 'height' => '18px' ); $form['icon'] = array ( 'form' => 'input', "type"=>"text", "name" => "分类图标", "class" => "txt", "description" => "", 'width' => '300px', 'height' => '18px' ); $form['sortid'] = array ( 'form' => 'input', "type"=>"text", "name" => "分类排序ID", "class" => "txt", "description" => "分类排序ID，产品分类从小到大排序", 'width' => '300px', 'height' => '18px' ); $form['main_tpl'] = array ( 'form' => 'input', "type"=>"text", "name" => "频道首页模板", "value" => (isset($theme_info['product_main_tpl']))? $theme_info['product_main_tpl'] : 'product', "class" => "txt", "description" => "频道首页要调用的模板名称", 'width' => '300px', 'height' => '18px' ); $form['list_tpl'] = array ( 'form' => 'input', "type"=>"text", "name" => "列表页模板", "value" => (isset($theme_info['product_list_tpl']))? $theme_info['product_list_tpl'] : 'product_list', "class" => "txt", "description" => "列表页要调用的模板名称", 'width' => '300px', 'height' => '18px' ); $form['detailed_tpl'] = array ( 'form' => 'input', "type"=>"text", "name" => "详细页模板", "value" => (isset($theme_info['product_detailed_tpl']))? $theme_info['product_detailed_tpl'] : 'detailed_tpl', "class" => "txt", "description" => "文章详细页要调用的模板名称", 'width' => '300px', 'height' => '18px' ); $form['display'] = array ( 'form' => 'input', "type"=>"text", "name" => "是否显示该分类", "value" => '1', "class" => "txt", "description" => "“1”显示分类，“4”隐藏分类", 'width' => '300px', 'height' => '18px' ); $seo['seo_title'] = array ( 'form' => 'input', "type"=>"text", "name" => "SEO标题", "class" => "txt", "description" => "", 'width' => '300px', 'height' => '18px' ); $seo['seo_description'] = array ( 'form' => 'textarea', "name" => "SE0描述", "class" => "txt", "description" => "SEO描述信息", 'width' => '300px', 'height' => '60px' ); $seo['seo_keywords'] = array ( 'form' => 'input', "type"=>"text", "name" => "SEO关键词", "class" => "txt", "description" => "", 'width' => '300px', 'height' => '18px' ); if (!empty($category)) { if (array_key_exists($category, $system_category)) foreach ($system_category[$category] as $k => $v) { if (array_key_exists($k, $form)) $form[$k]['value'] = $v; if (array_key_exists($k, $seo)) $seo[$k]['value'] = $v; } $form['category']['value'] = $category; } include SITE_ROOT . "/admin/tpl/system_category_product_edit.tpl.php"; } ?>